export const createCommonPage = (page = {}) => ({ pageNo: page.pageNo || 1, pageSize: page.pageSize || 15 })

export const createCommonPagination = (total) => ({ total: total || 0 })

export const COLUMN_WIDTH = 120

export const manuTypeMap = Object.freeze({
  VIDEO: {
    icon: 'video',
    title: '视频',
  },
  IMAGE: {
    icon: 'image',
    title: '图文',
  },
})

export const createForm = (orderField) => ({
  desc: true, // 是否降序排序,默认false
  orderField: orderField == undefined ? 'createTime' : orderField, // 排序字段
  field: '', // 领域分类
  product: '', // 产品分类
  state: '', // 状态
  theme: '', // 主题
  title: '',
  organ: '',
  username: '',
  startTime: '',
  endTime: '',
  timeType: '', // 时间类型:全部,今天,昨天,本周,本月,本季,本年,近n天,近n周,近n月,近n季,近半年,自定义
  ...createCommonPage(),
})

/* 用户权限 */
const storage = window.sessionStorage
/* const a = storage.getItem('userAuthority')
if (!a) {
  // storage.setItem('userAuthority', 'provideEnd')
  storage.setItem('userAuthority', 'manageEnd')
} */

export const getLocalUserAuthority = () => storage.getItem('userAuthority')
export const setLocalUserAuthority = (value) => storage.setItem('userAuthority', value)

export const getUserAuthority = () => {
  const a = storage.getItem('userAuthority')
  return new Promise((resolve) => setTimeout(resolve, 0, a))
}
